//
//  BannerView.swift
//  BasicTools
//
//  Created by ikang on 2025/8/19.
//

import SwiftUI

public enum BannerType {
    case vertical
    case horizontal
}

public struct BannerView: View {
    // Banner滑动方向
    var type: BannerType = .horizontal
    
    public init(type: BannerType) {
        self.type = type
    }
    
    public var body: some View {
        GeometryReader { proxy in
            if self.type == .vertical {
                ScrollView(.vertical) {
                    LazyVStack { 
                        Rectangle()
                            .background(.red)
                            .frame(
                                width: proxy.size.width,
                                height: proxy.size.height
                            )
                        
                        Rectangle()
                            .background(.blue)
                            .frame(width: proxy.size.width, height: proxy.size.height)
                        
                        Rectangle()
                            .background(.green)
                            .frame(width: proxy.size.width, height: proxy.size.height)
                    }
                }
                .frame(width: proxy.size.width, height: proxy.size.height)
//                .scrollIndicators(.hidden)
                
            }else if self.type == .horizontal {
                ScrollView(.horizontal) {
                    LazyHStack {
                        Rectangle()
                            .background(.red)
                            .frame(width: proxy.size.width, height: proxy.size.height)
                        
                        Rectangle()
                            .background(.blue)
                            .frame(width: proxy.size.width, height: proxy.size.height)
                        
                        Rectangle()
                            .background(.green)
                            .frame(width: proxy.size.width, height: proxy.size.height)
                    }
                }
                .frame(width: proxy.size.width, height: proxy.size.height)
//                .scrollIndicators(.hidden)
//                .scrollIndicators(.hidden)
//                .hidden
            }
            
        }
    }
    
    @ViewBuilder
    func ss() -> some View {
        Rectangle()
            .background(.red)
//            .frame(width: proxy.size.width, height: proxy.size.height)
        
        Rectangle()
            .background(.blue)
//            .frame(width: proxy.size.width, height: proxy.size.height)
        
        Rectangle()
            .background(.green)
//            .frame(width: proxy.size.width, height: proxy.size.height)
    } 
}

#Preview {
    BannerView(type: .vertical)
}
